using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMContract_TypeController
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGirdTMContract_Type()
        {
            return cls.BindGridData("sp_TMContract_Type");
        }
        public DataTable BindGirdTMContract_Type_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMContract_Type_Detail_Edit", "@Type_Of_Contract_ID", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMContract_Type(clsTMContract_TypeProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Type_Of_Contract_Alias", data.Type_Of_Contract_Alias);
            cls.AddParameter("@Type_Of_Contract_Name", data.Type_Of_Contract_Name);
            cls.AddParameter("@Type_Of_Contract_Note", data.Type_Of_Contract_Note);
            cls.AddParameter("@ServicesFOB_ID", data.ServicesFOB_ID);
            cls.ExecuteNonQuery("sp_TMContract_Type_Insert");
            return true;
        }
        public bool UpdateTMContract_Type(clsTMContract_TypeProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Type_Of_Contract_ID", data.Type_Of_Contract_ID);
            cls.AddParameter("@Type_Of_Contract_Alias", data.Type_Of_Contract_Alias);
            cls.AddParameter("@Type_Of_Contract_Name", data.Type_Of_Contract_Name);
            cls.AddParameter("@Type_Of_Contract_Note", data.Type_Of_Contract_Note);
            cls.AddParameter("@ServicesFOB_ID", data.ServicesFOB_ID);
            cls.ExecuteNonQuery("sp_TMContract_Type_Edit");
            return true;
        }
        public bool DeleteTMContract_Type(int id)
        {
            cls.Delete("sp_TMContract_Type_Delete", "@Type_Of_Contract_ID", id);
            return true;
        }
        public bool TMContract_Type_Check_TMContract(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMContract_Type_Check_TMContract", "@ID", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        #endregion

        #region[Search]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMContract_Type_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}